﻿<Serializable()> Public Class SectionPoint
    ''' <summary>
    ''' 断面点原始数据：点号、垂直角、斜距；   
    ''' 断面点与计算相关的属性：坐标、方位、有效性
    ''' </summary>
    ''' <remarks></remarks>
    Public Name As String = ""         '点号
    Public Hv As Double = 0            '垂直角
    Public SlopeDist As Double = 0     '斜距

    Public Coor As New TSPCoor(0, 0)   '坐标
    Public AzimFromCenter As Double    '中心点至该点的方位
    Public Dist_frm_Center As Double   '中心店至该点的距离,应同2.75相似
    Public Err_Distance As Double      '该点同设计值或者该点同上次值比较的差值
    Public IsValid As Boolean = True   '有效性
    Public Err_Simulation As Double    '该点的拟合残差

    Sub New(ByVal Name As String, ByVal Hv As String, ByVal SlopeDist As String)
        Me.Name = Name
        Me.Hv = CDbl(Hv)
        Me.SlopeDist = CDbl(SlopeDist)
    End Sub
    Sub New()

    End Sub

    ''' <summary>
    '''计算水平向，垂直向坐标值 
    ''' </summary>
    ''' <param name="BaseAtPoint"></param>
    ''' <remarks></remarks>
    Sub CalculateCoor(ByVal BaseAtPoint As TSPCoor)
        Dim radHv As Double = (Hv)
        Coor.Coor_V = BaseAtPoint.Coor_V + SlopeDist * Math.Cos(radHv)
        Coor.Coor_H = BaseAtPoint.Coor_H + SlopeDist * Math.Sin(radHv)
    End Sub

    ''' <summary>
    '''输出原始观测数据 
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Overrides Function ToString() As String
        Dim sTmp As String = String.Format("{0,4}", Name) & ","
        sTmp &= String.Format("{0,9}", String.Format("{0:0.0000}", Hv)) & ","
        sTmp &= String.Format("{0,6}", String.Format("{0:0.000}", SlopeDist))
        Return sTmp
    End Function


    ''' <summary>
    '''计算自中心点的方位 
    ''' </summary>
    ''' <param name="Center"></param>
    ''' <remarks></remarks>
    Public Function AzimFrom(ByVal Center As TSPCoor) As Double
        If Center Is Nothing Then
            Return 0

            Throw New ApplicationException("Exception Occured")
        End If
        Dim vct As New SvVector(Center, Me.Coor)
        AzimFromCenter = vct.Azimuth
        Return AzimFromCenter
    End Function

End Class

